public class MainForm extends From {
    private Point p1;
    private Point p2;

    private ArrayList<Line> lineVector = new ArrayList<>();
    private ArrayList<Rectangle> rectVector = new ArrayList<>();
    //改变
    private ArrayList<Circle> circleVector = new ArrayList<>();

    public MainForm(){
        //...
    }

    public void mousePressed(MouseEvent e) {
        p1 = new Point(e.getX(), e.getY());
        //...
    }

    public void mouseReleased(MouseEvent e) {
        p2 = new Point(e.getX(), e.getY());

        if (rdoLine.isSelected()){
            Line line = new Line(p1, p2);
            lineVector.add(line);
        }
        else if (rdoRect.isSelected()){
            int width = Math.abs(p2.x - p1.x);
            int height = Math.abs(p2.y - p1.y);
            Rectangle rect = new Rectangle(p1.x, p1.y, width, height);
            rectVector.add(rect);
        }
        //改变
        else if (...){
            //...
            circleVector.add(circle);
        }

        //...
    }

    public void paint(Graphics g) {
        //针对直线
        for (Line line : lineVector){
            g.drawLine(line.start.x, line.start.y, line.end.x, line.end.y);
        }

        //针对矩形
        for (Rectangle rect : rectVector){
            g.drawRect(rect.x, rect.y, rect.width, rect.height);
        }

        //改变
        //针对圆形
        for (Circle circle : circleVector){
            g.drawOval(circle.x, circle.y, circle.radius, circle.radius);
        }
    }
}

